﻿<UserControl x:Class="MissedMemo.MeatAndCheeseDisc.OrderEntry.viewOrderDetails"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:data="clr-namespace:MissedMemo.MeatAndCheeseDisc.BusinessLogic;assembly=BusinessObjects"
    xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderEntry"
    Height="300" Width="300">
    
    <UserControl.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="resColors.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="PizzaTypes">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="data:PizzaType" />
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>

            <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="PizzaSizes">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="data:PizzaSize" />
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>

            <DataTemplate x:Key="OrderItemTemplate">
                <DockPanel>
                    <Button Content="X" Foreground="Red" FontWeight="Bold" ToolTip="Delete Item" Click="btnX_Click" />
                    <TextBlock Margin="2,0,0,0" VerticalAlignment="Center" Text="{Binding ItemType}" />
				</DockPanel >
            </DataTemplate>

            <local:FormattedTextConverter x:Key="StringFormatConverter" />

        </ResourceDictionary>
    </UserControl.Resources>
    
    
    <Grid Margin="10">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" Margin="0,5,0,10" Header="Add Pizza">
            <Grid>

                <Grid.Resources>
                    <Style TargetType="ComboBox">
                        <Setter Property="SelectedIndex" Value="0" />
                        <Setter Property="Margin" Value="3" />
                        <Setter Property="Background" Value="Transparent" />
                    </Style>
                </Grid.Resources>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>

                <ComboBox Grid.Column="0" Name="comboPizzaType" ItemsSource="{Binding Source={StaticResource PizzaTypes}}" />
                <ComboBox Grid.Column="1" Name="comboPizzaSize" ItemsSource="{Binding Source={StaticResource PizzaSizes}}" />
                <Button Grid.Column="2" Padding="5,2" Margin="3" Content="Add" Click="btnAddItem_Click" />

            </Grid>
        </GroupBox>

       <ListView Name="listOrderItems" Grid.Row="1" Margin="0,8" ItemsSource="{Binding OrderItems}" >
            <ListView.View>
                <GridView >
                    <GridViewColumn Header="Item" Width="150" CellTemplate="{StaticResource OrderItemTemplate}"/>
                    <GridViewColumn Header="Size" Width="100" DisplayMemberBinding="{Binding Size}"/>
                    <GridViewColumn Header="Price" Width="60" DisplayMemberBinding="{Binding Cost, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:C2}'}"/>
                </GridView>
            </ListView.View>
        </ListView>
        
        <Grid Grid.Row="2" Margin="10">
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="20" />
                <RowDefinition Height="20" />
                <RowDefinition Height="20" />
            </Grid.RowDefinitions>
            
            <TextBlock Grid.Row="0" Grid.Column="0" Text="Ordered:" />
            <TextBlock Grid.Row="0" Grid.Column="1" Margin="8,0,0,0"
                       Text="{Binding DateTimeOrderPlaced, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:M/d/yy  h:mm tt}'}" />
            
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Expected:" />
            <TextBlock Grid.Row="1" Grid.Column="1" Margin="8,0,0,0"
                       Text="( + 30 min. )" />
            
            <TextBlock Grid.Row="0" Grid.Column="3" Text="SubTotal:" />
            <TextBlock Grid.Row="0" Grid.Column="4"
                       Text="{Binding CostPreTax, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0,8:C2}'}" />
		    
            <TextBlock Grid.Row="1" Grid.Column="3" Text="Local Tax:" />
            <TextBlock Grid.Row="1" Grid.Column="4" 
                       Text="{Binding Tax, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0,8:C2}'}" />
            
            <Line Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="2" Stroke="Black" X2="120" />
            <TextBlock Grid.Row="2" Grid.Column="4" FontWeight="Bold"
                       Text="{Binding TotalCost, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0,8:C2}'}" />

        </Grid>
        
    </Grid>
    
</UserControl>
